package com.extension.company.model.main;

import android.content.Context;

import com.extension.company.Constant;
import com.extension.company.model.entity.LoginQuite;
import com.extension.company.common.http.RetrofitHelper;
import com.extension.company.common.utils.ToastUtil;
import com.extension.company.contract.main.FragmentMyContract;
import com.extension.company.model.api.RetrofitUrlApi;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * 作者:zwk
 * 联系方式：497981239@qq.com
 * 时间：on 2019/7/4 12:45
 * 功能：
 */
public class FragmentMyModel implements FragmentMyContract.Mode {

	RetrofitUrlApi retrofitUrlApi = RetrofitHelper.getRetrofit().create(RetrofitUrlApi.class);

	/**
	 *
	 */
	public void quiteLogin(final Context context) {
		String sign = "123456";
		String token = Constant.TOKEN;

		retrofitUrlApi.LoginOut(sign, token)
				.observeOn(AndroidSchedulers.mainThread())
				.subscribeOn(Schedulers.io())
				.subscribe(new Observer<LoginQuite>() {
					@Override
					public void onSubscribe(Disposable d) {

					}

					@Override
					public void onNext(LoginQuite loginQuite) {
						if (200 == loginQuite.getCode()) {
							ToastUtil.showToast(context, loginQuite.getMsg() == null ? "null" : loginQuite.getMsg());
						}

					}

					@Override
					public void onError(Throwable e) {

					}

					@Override
					public void onComplete() {

					}
				});
	}
}
